package com.naodong.shenluntiku.mvp.view.activity;

import android.content.Intent;
import android.os.Bundle;

import com.naodong.shenluntiku.R;
import com.naodong.shenluntiku.mvp.model.data.manager.TokenManager;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import me.shingohu.man.base.BaseMVPActivity;
import me.shingohu.man.di.component.AppComponent;

/**
 * Created by hujie on 17/4/24.
 */

public class LauncherActivity extends BaseMVPActivity {


    @Override
    protected void onCreateInit(Bundle savedInstanceState) {

        Observable.timer(3, TimeUnit.SECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(aLong -> {
                    Intent intent = null;
                    if (TokenManager.getInstance().hasLoginAndExpires()) {
                        intent = new Intent(mActivity, MainActivity.class);
                    } else {
                        intent = new Intent(mActivity, GetVerCodeActivity.class);
                    }
                    startActivity(intent);
                    finish();
                });
    }


    @Override
    protected void setupActivityComponent(AppComponent appComponent) {


    }

    @Override
    public void onBackPressedSupport() {

    }

    @Override
    public boolean supportActionbar() {
        return false;
    }


    @Override
    public void overridePendingTransition(int enterAnim, int exitAnim) {
        super.overridePendingTransition(0, 0);
    }


    @Override
    protected int layoutId() {
        return R.layout.a_launch;
    }


}
